﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Model.WaiGaoQiao;
using WaiGaoQiaoWeb.Models;
using WaiGaoQiaoWeb.JsonEntities;
using System.Data;
using AutoMapper;
using System.IO;

namespace WaiGaoQiaoWeb.Controllers
{
    public class XiYiDaoRuController : Controller
    {
        private XiYiDaoRuInfo meninfo = new XiYiDaoRuInfo();
        public ActionResult XiYiDaoRuIndex()
        {
            return View();
        }

        /// <summary>
        /// 上传
        /// </summary>
        /// <param name="collection"></param>
        /// <param name="importFile"></param>
        /// <returns></returns>
        public ActionResult Import(FormCollection collection, HttpPostedFileBase importFile)
        {
            string path = collection["h_filePath"];
            string strToFilePath = "/";
            string strToFileFullPath = HttpContext.Server.MapPath(strToFilePath);
            if (!Directory.Exists(strToFileFullPath))
            {
                Directory.CreateDirectory(strToFileFullPath);
            }
            string fileNamea = "F21B.xls";
            string strToFile = strToFileFullPath + fileNamea;
            importFile.SaveAs(strToFile);
            return Json(1);
        }

        public ActionResult FileUp1(string filename)
        {
            string strToFilePath = "/";
            string strToFileFullPath = HttpContext.Server.MapPath(strToFilePath);
            string fileNamea = "F21B.xls";
            // 将要保存的完整文件名
            string strToFile = strToFileFullPath + fileNamea;
            string strfilename = strToFile;
            string Operator = ((LogOnModel)(System.Web.HttpContext.Current.Session["user"])).LogName;
            string i = meninfo.ExcelDataSource(strfilename, "发券", Operator);
            return Json(i);
        }
    }
}
